﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Pg.BioMedics.SDR.Client.Multimedia
{
    /// <summary>
    /// Provides utility methods for sending commands to MCI subsystem
    /// </summary>
    internal class MCIHelper
    {
        #region Static methods

        internal static void OpenWaveAudio()
        {
            mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
        }

        internal static void Record()
        {
            mciSendString("record recsound", "", 0, 0);
        }

        internal static void Save(string fileName)
        {
            mciSendString(String.Format("save recsound {0}", fileName), "", 0, 0);
        }

        internal static void Close()
        {
            mciSendString("close recsound ", "", 0, 0);
        }

        #endregion

        #region External methods

        [DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);

        #endregion
    }
}
